package com.itqf.controller;

import com.itqf.bean.Bill;
import com.itqf.bean.Param;
import com.itqf.service.BillService;
import com.itqf.vo.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("bill")
public class BillController {

    @Autowired
    private BillService billService;

    /**
     * 供应商展示,下拉列表展示接口
     */
    @GetMapping("providers")
    public Object providers() {
        //1.参数接受 2.调用service
        ResultVO resultVO = billService.findProviders();
        //3.响应数据
        return resultVO;
    }

    //账单展示
    @GetMapping("list")
    public Object billList() {
        ResultVO resultVO = billService.findBills();

        return resultVO;
    }

    //添加账单
    @PostMapping(value = "save", consumes = "application/json;charset=utf-8")
    public Object save(@RequestBody Bill bill) {
        ResultVO resultVO = billService.saveBills(bill);

        return resultVO;
    }

    //修改账单
    @PostMapping(value = "update", consumes = "application/json;charset=utf-8")
    public Object update(@RequestBody Bill bill) {
        ResultVO resultVO = billService.updateBills(bill);

        return resultVO;
    }

    //查看账单
    @GetMapping("info")
    public Object info(int id) {
        ResultVO resultVO = billService.infoBills(id);

        return resultVO;
    }

    //删除账单
    @GetMapping("remove")
    public Object remove(int id) {
        ResultVO resultVO = billService.removeBills(id);

        return resultVO;
    }

    //模糊查询
    @PostMapping(value = "search",consumes = "application/json;utf-8")
    public Object serach(@RequestBody Param param){

        ResultVO resultVO = billService.serachBills(param);

        return resultVO;

    }


}